package com.example.mapper;

import com.example.entity.Account;
import com.example.entity.Student;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 操作student相关数据接口
*/
public interface StudentMapper {

    /**
      * 新增
    */
    int insert(Student student);

    /**
      * 删除
    */
    int deleteById(Integer id);

    /**
      * 修改
    */
    int updateById(Student student);

    /**
      * 根据ID查询
    */
    Student selectById(Integer id);

    /**
      * 查询所有
    */
    List<Student> selectAll(Student student);

    @Select("select s.*,c.teacher_id as teacherId from student s  left join classes c on s.class_id = c.id where username = #{username}")
    Student selectByUsername(String username);

    @Select("select * from student where name = #{name}")
    Student selectByname(String s);

    @Select("select s.*,c.name as className,c2.name as collegeName,s2.name as specialityName from student s\n" +
            "left join classes c on s.class_id = c.id\n" +
            "left join college c2 on s.college_id = c2.id\n" +
            "left join speciality s2 on s.speciality_id = s2.id\n" +
            "where s.username = #{username};")
    Student selectByUsername2(String username);
}